package models;

import play.*;
import play.data.binding.As;
import play.db.jpa.*;
import play.modules.search.*;

import javax.persistence.*;

import java.util.*;

@Indexed
@Entity
public class Comment extends Model {
    
	@Field
	public String content;
    
    @As("yyyy-MM-dd")
    public Date postedAt;
    
    @Field
    @ManyToOne
    public User postedBy;
    
    @ManyToOne
    public Lecture lecture;
    
    @ManyToOne
    public Question question;
    
    //Constructor
    public Comment(Lecture lecture, User postedBy, String content) {
    	this.lecture = lecture;
    	this.postedBy = postedBy;
    	this.content = content;
    	this.postedAt = new Date();
    	create();
    }
    
    public Comment(Question question, User postedBy, String content) {
    	this.question = question;
    	this.postedBy = postedBy;
    	this.content = content;
    	this.postedAt = new Date();
    	create();
    }
}
